import { getimg, yzm, login } from "../../api/userdata"
import storage from "@/utils/storage"


export default {
  namespaced: true,
  state: {
    userdata: storage.getItem("userdata")
  },
  mutations: {
    set_data(state, payload) {
      state.userdata = payload
    }
  },
  actions: {
    login({ commit }, payload) {
      console.log(payload);
      return new Promise((resolve, reject) => {
        login(payload).then(res => {
          // console.log(res);
          storage.setItem("userdata", res.data.data)
          commit("set_data", res.data.data)
          resolve(res.data.data)
        }).catch(err => {
          return reject(err)
        })
      })
    },
    getimg({ commit }, payload) {
      return new Promise((resolve, reject) => {
        getimg().then(res => {

          // console.log(res.data.data);
          resolve(res.data.data)
        })

      })
    },
    yzm() {
      return new Promise((resolve, reject) => {
        yzm().then(res => {

          resolve(res.data.data)
        })
      })
    }
  },
  modules: {
  }
}